package com.charles.springcloud.controller;

import com.charles.common.CommonResult;
import com.charles.springcloud.entity.Payment;
import com.charles.springcloud.service.PaymentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: 风中灵劲草
 * @Date: 2021/08/21/16:33
 * @Description:
 */
@RestController
@Slf4j
public class PaymentController {
    @Value("${server.port}")
    private String serverPort;

    @Autowired
    PaymentService paymentService;

    @GetMapping("/payment/nacos/{id}")
    public String getPayment(@PathVariable("id") Long id) {
        return "nacos注册成功,serverPort=" + serverPort + "\t" + ",id=" + id;
    }

    @GetMapping("/getPayment/{id}")
    public CommonResult<Payment> getPaymentById(@PathVariable("id") Long id) {
        Payment payment = paymentService.getPaymentById(id);
        return CommonResult.success(payment);
    }
}
